package es.xpt.ysf.model;

import java.util.ArrayList;
import java.util.List;

import es.xpt.ysf.YSFException;

public class ItemResponse<E> {

	private List<YSFException> errors;
	private List<YSFException> warns;
	private List<MessageWithParams> infoMessages;
	private List<MessageWithParams> errorMessages;
	private List<MessageWithParams> warnMessages;
	private E object;
	
	public ItemResponse() {
		super();		
	}
	
	public void addInfoMessage (String message, Object... params) {
		MessageWithParams m = new MessageWithParams(message, params);
		if ( infoMessages == null ) {
			infoMessages =  new ArrayList<MessageWithParams>(2);
		}
		infoMessages.add(m);
	}
	
	public void addErrorMessage (String message, Object... params) {
		MessageWithParams m = new MessageWithParams(message, params);
		if ( errorMessages == null ) {
			errorMessages =  new ArrayList<MessageWithParams>(2);
		}
		errorMessages.add(m);
	}
	
	public void addWarnMessage (String message, Object... params) {
		MessageWithParams m = new MessageWithParams(message, params);
		if ( warnMessages == null ) {
			warnMessages =  new ArrayList<MessageWithParams>(2);
		}
		warnMessages.add(m);
	}

	
	
	public List<YSFException> getErrors() {
		if ( errors == null )
			errors = new ArrayList<YSFException>(2);
		return errors;
	}
	
	public List<YSFException> getWarns() {
		if ( warns == null )
			warns = new ArrayList<YSFException>(2);
		return warns;
	}

	public List<MessageWithParams> getWarnMessages() {
		return warnMessages;
	}

	public List<MessageWithParams> getInfoMessages() {
		return infoMessages;
	}
	
	/**
	 * @return the errorMessages
	 */
	public List<MessageWithParams> getErrorMessages() {
		return errorMessages;
	}
	
	/**
	 * @return the object
	 */
	public E getObject() {
		return object;
	}
	/**
	 * @param object the object to set
	 */
	public void setObject(E object) {
		this.object = object;
	}

}
